﻿using BMSPlatform.ViewModel;
using System.Windows;
using System.Windows.Controls;

namespace BMSPlatform.View
{
    /// <summary>
    /// DeviceConnectedView.xaml 的交互逻辑
    /// </summary>
    public partial class DeviceConnectedView : UserControl
    {
        public DeviceConnectedViewModel VM => this.DataContext as DeviceConnectedViewModel;

        public DeviceConnectedView()
        {
            InitializeComponent();
        }
        private void CANConnected_Click(object sender, RoutedEventArgs e)
        {
            // 在这里实现控制主窗体控件使能的逻辑
            MainWindow mainWindow = Window.GetWindow(this) as MainWindow;
            if (mainWindow != null) mainWindow.VM.IsControlEnable = false;
           
            VM.OnOpenDevice();

            if (mainWindow != null) mainWindow.VM.IsControlEnable = true;
        }

        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            if (VM.CANStart) VM.OnCloseDevice();
        }
    }
}
